<?php
/*
 * 手机客户端 用户支付明细函数
 * 2013-12-02
 */
 
 
 /**
  * 已支付
  */
 function userwon_paidauctionlist($uid){
	$sql = "
			select 
					d.aid
					,d.acode
					,d.auction
					,date_format(c.asprevtime,'%Y-%m-%d %H:%i:%s') as prevtime
					,date_format(c.asopentime,'%Y-%m-%d %H:%i:%s') as starttime
					,date_format(c.asclosetime,'%Y-%m-%d %H:%i:%s') as endtime
					,if(c.asprevtime>now(),'-1',if(c.asprevtime<now() and c.asprevclosetime>now(),0,if(c.asopentime<now() and c.asclosetime>now(),1,2))) as auctiontype
					,d.bid_amount as lastprice
					,c.astag as atag
			from 
					auction_userlastbid  a 
					left outer join auction b on a.aid=b.aid  
					left outer join auction_special c on b.asid=c.asid 
					left outer join auction_userwon d on a.wonid=d.wonid 
					left outer join auction_userwonpaid e on d.paidid=e.paidid   
			where
					a.uid='".$uid."' 
					and c.astag>0
					and a.is_bid=1 
					and a.pay_status=2 
					and a.aid in (select aid from auction where asid in (select asid from auction_special where now() > asclosetime))
	";
	$db = $GLOBALS['db'];
	return $db->queryArray($sql);
 }
 
 
 /**
  * 已发货物流单拍品列表
  */
 function userwon_shipallwonlist12($uid){
	$sql = "
			select 
					d.aid
					,d.acode
					,d.auction,
 
					date_format(c.asprevtime,'%Y-%m-%d %H:%i:%s') as prevtime,
					date_format(c.asopentime,'%Y-%m-%d %H:%i:%s') as starttime,
					date_format(c.asclosetime,'%Y-%m-%d %H:%i:%s') as endtime,
					if(c.asprevtime>now(),'-1',if(c.asprevtime<now() and c.asprevclosetime>now(),0,if(c.asopentime<now() and c.asclosetime>now(),1,2))) as auctiontype,
				
					d.limittime
					,d.bid_amount as lastprice
					,c.astag as atag
			from
					auction_userlastbid  a 
					left outer join auction b on a.aid=b.aid   
					left outer join auction_special c on b.asid=c.asid  
					left outer join auction_userwon d on a.wonid=d.wonid 
					left outer join auction_userwonpaid e on d.paidid=e.paidid
			where
					a.uid='".$uid."' 
					and c.astag>0
					and a.is_bid=1 and a.pay_status=2 
					and a.aid in (select aid from auction where asid in (select asid from auction_special where now() > asclosetime) )
					and a.aulbid  in (select aulbid from  auction_userwon where paidid in (select paidid from auction_userwonpaid where pay_status=2 and ship_status=2))

			order by
					d.aid desc
	";
	$db = $GLOBALS['db'];
	return $db->queryArray($sql);
 }
 
 /**
  * 未发货
  */
 function userwon_shipallwonlist03($uid,$attention,$gzIds){
	$sql = "
			select
				a.aid,
				a.acode,
				a.auction,
				date_format(c.asprevtime,'%Y-%m-%d %H:%i:%s') as prevtime,
				date_format(c.asopentime,'%Y-%m-%d %H:%i:%s') as starttime,
				date_format(c.asclosetime,'%Y-%m-%d %H:%i:%s') as endtime,
				if(c.asprevtime>now(),'-1',if(c.asprevtime<now() and c.asprevclosetime>now(),0,if(c.asopentime<now() and c.asclosetime>now(),1,2))) as auctiontype,
				a.limittime,
				a.bid_amount as lastprice,
				c.astag as atag
			from
				auction_userwon a
				inner join auction b on b.aid = a.aid
				inner join auction_special c on b.asid=c.asid
				inner join auction_userwonpaid d on d.paidid = a.paidid
			where 
				d.uid = '".$uid."' 
				and c.astag>0
				and (d.ship_status = 0 or d.ship_status = 3)
	";
	if(!$gzIds){
		$gzIds = "0";
	}
	if($attention=="0"){
		$sql = $sql." and b.aid not in (".$gzIds.")";
	}else if($attention=="1"){
		$sql = $sql." and b.aid in (".$gzIds.")";
	}
	$sql = $sql." order by b.aid desc";
	$db = $GLOBALS['db'];
	return $db->queryArray($sql);
 }
 ?>